import {axios} from "../utils/request";
import global from "../store/global";

const api = global.serverAddress + "/node";


// 根据graphId获得一个Graph的所有节点
export function getGraphNodesByIdAPI(graphId) {
    return axios({
        url: `${api}/get_graph/${graphId}`,
        method: "GET"
    });
}

// 根据id获得一个node
export function getNodeByIdAPI(id) {
    return axios({
        url: `${api}/get/${id}`,
        method: "GET"
    });
}

// 根据name在知识图谱中模糊查询node
export function searchGraphNodesAPI(params) {
    return axios({
        url: `${api}/get/${params.graphId}/${params.name}`,
        method: "GET"
    });
}

// 按照表单自定义添加node
export function addNodeAPI(node) {
    return axios({
        url: `${api}/add/${node.graphId}`,
        method: "POST",
        data: node.node
    });
}

// 根据name在id为graphId的图谱上添加node
export function addNodeByNameAPI(params) {
    return axios({
        url: `${api}/add/${params.graphId}/${params.name}`,
        method: "POST"
    });
}

// 根据id删除node
export function deleteNodeByIdAPI(id) {
    return axios({
        url: `${api}/delete/${id}`,
        method: "POST"
    });
}

// // 根据id更新node
export function updateNodeAPI(node) {
    return axios({
        url: `${api}/update`,
        method: "POST",
        data: node
    });
}

